package net.zoneland.knowledge.enums;

/**
 * 操作类型枚举.
 */
public enum OperatorTypeEnum {

    ADD(0, "add", "新增"),
    UPDATE(1,"update", "修改"),
    DELETE(2, "delete", "删除");

    /**
     * 聚合编号.
     */
    private int operatorNum;

    /**
     * 聚合编号.
     */
    private String operatorCode;

    /**
     * 聚合名称.
     */
    private String operatorName;

    OperatorTypeEnum(final int operatorNum, final String operatorCode, final String operatorName) {
        this.operatorNum = operatorNum;
        this.operatorCode = operatorCode;
        this.operatorName = operatorName;
    }

    public int getOperatorNum() {
        return operatorNum;
    }

    public String getOperatorCode() {
        return operatorCode;
    }

    public String getOperatorName() {
        return operatorName;
    }

    public static OperatorTypeEnum getOperatorTypeEnumByCode(final String operatorCode) {
        for (OperatorTypeEnum typeEnum: OperatorTypeEnum.values()) {
            if (typeEnum.getOperatorCode().equals(operatorCode)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static OperatorTypeEnum getOperatorTypeEnumByName(final String operatorName) {
        for (OperatorTypeEnum typeEnum: OperatorTypeEnum.values()) {
            if (typeEnum.getOperatorName().equals(operatorName)) {
                return typeEnum;
            }
        }
        return null;
    }

}
